package ch.bfh.medinfo.javafx.dice.implementation;

import java.util.Arrays;

import ch.bfh.medinfo.javafx.dice.definition.Dice;
import ch.bfh.medinfo.javafx.dice.definition.StatisticalDice;

public class ComposedStatisticalDice implements StatisticalDice {
	private Dice dice;
	private int[] statistics;

	public ComposedStatisticalDice(Dice dice) {
		this.dice = dice;
		this.statistics = new int[Math.abs(getMaxValue() - getMinValue()) + 1];
	}

	@Override
	public void play() {
		this.dice.play();
		// update the statistics
		this.statistics[Math.abs(this.getActualValue() - this.getMinValue())]++;

	}

	@Override
	public int getActualValue() {
		return this.dice.getActualValue();
	}

	@Override
	public int getMinValue() {
		return this.dice.getMinValue();
	}

	@Override
	public int getMaxValue() {
		return this.dice.getMaxValue();m
	}

	@Override
	public int[] getStatistics() {
		return Arrays.copyOf(statistics, statistics.length);
	}
}
